package hapi.util;

class CodeGenerator {

	static inline var ALPHA_NUM_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	static var ALPHA_NUM_LENGTH = ALPHA_NUM_CHARS.length;
	
	public static function generateAlphanumeric(?length:Int=32){
		var buf = new StringBuf();
		for (i in 0 ...length ){
			buf.add( ALPHA_NUM_CHARS.charAt( Std.int(Math.random() * ALPHA_NUM_LENGTH)) );
		}
		return buf.toString();
	}
	
	public static function generateNumeric(?length:Int=32){
		var buf = new StringBuf();
		for (i in 0 ...length ){
			buf.add(Std.string(Math.random() * 10));
		}
		return buf.toString();
	}
}